<%--
  Created by IntelliJ IDEA.
  User: w1057229265
  Date: 2021/6/22
  Time: 11:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="../static/plugins/jquery-easyui-1.9.15/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../static/plugins/jquery-easyui-1.9.15/themes/icon.css">
    <script type="text/javascript" src="../static/plugins/jquery-easyui-1.9.15/jquery.min.js"></script>
    <script type="text/javascript" src="../static/plugins/jquery-easyui-1.9.15/jquery.easyui.min.js"></script>
    <script>
        $(function (){
            $('#dg').datagrid({
                url: '/ServletCar?action=getdglist1',
                toolbar: '#tb',
                pagination: true,
                fit: true,
                singleSelect: true,
                columns: [[
                    {field: 'id', title: '订单号', width: 100},
                    {field: 'sname', title: '书名', width: 100},
                    {field: 'number', title: '数量', width: 100},
                    {field: 'price', title: '价格', width: 100},
                    {field: 'time', title: '时间', width: 100}
                ]]
            });
            $('#btnDelete').click(function () {
                $.messager.confirm('提示', '是否要删除该数据？', function (r) {
                    if (r) {
                        let ro = $('#dg').datagrid("getSelected");
                        $.ajax({
                            type: "GET",
                            url: "/ServletCar?action=delete",
                            data: {bname: ro.bname},
                            success: function (ret) {
                                let result = eval("(" + ret + ")");
                                if (result.code == "200") {
                                    $.messager.show({
                                        title: '提示',
                                        msg: result.msg,
                                        showType: 'show',
                                        timeout: 2000,
                                        showType: 'slide'
                                    });
                                    $('#dg').datagrid('reload');
                                } else {
                                    $.messager.alert('提示', result.msg, 'warning');

                                }

                            }
                        })
                    }
                })
            })
        })
    </script>
</head>

<body class="easyui-layout">
<div data-options="region:'center',border:false">
    <table id="dg">

    </table>
</div>
<div id="tb" style="height:auto">
    <table>
        <tr>
            <td><a id="btnDelete" href="javascript:void(0)" class="easyui-linkbutton"
                   data-options="iconCls:'icon-remove',plain:true">删除</a>
            </td>

        </tr>
    </table>
</div>
</body>
</html>